package clienteguiview;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JOptionPane;
import javax.swing.JTabbedPane;
import javax.swing.JLabel;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JTextField;

import clientes.controle.clienteControle;
import clientes.exceptions.Erro_Cpf;
import clientes.exceptions.Erro_Nome;
import javax.swing.AbstractAction;
import javax.swing.Action;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class clienteVisaoPrincipal extends JFrame {

	private JPanel contentPane;
	private JTextField textFieldCpf;
	

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					clienteVisaoPrincipal frame = new clienteVisaoPrincipal();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public clienteVisaoPrincipal() {
		setTitle("Loja Facil");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 463, 368);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(null);
		setContentPane(contentPane);
		
		JButton btnCadastrar = new JButton("Sair");
		btnCadastrar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			System.exit(0);
			}
		});
		btnCadastrar.setBounds(348, 285, 89, 23);
		contentPane.add(btnCadastrar);
		
		JLabel lblCadastroDoCliente = new JLabel("Para localizar o cliente digite seu cpf :  ");
		lblCadastroDoCliente.setBounds(21, 31, 276, 14);
		contentPane.add(lblCadastroDoCliente);
		
		JLabel lblCpf = new JLabel("Cpf:");
		lblCpf.setBounds(10, 113, 46, 14);
		contentPane.add(lblCpf);
		
		textFieldCpf = new JTextField();
		textFieldCpf.setToolTipText("Campo destinado a Pesquisa do Cliente");
		textFieldCpf.setBounds(56, 110, 153, 20);
		contentPane.add(textFieldCpf);
		textFieldCpf.setColumns(10);
		
		JButton btnNovoCliente = new JButton("Novo Cliente");
		btnNovoCliente.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				
				FrmNovoCliente frame = new FrmNovoCliente();
				frame.setVisible(true);
			}
		});
		btnNovoCliente.setBounds(10, 163, 139, 23);
		contentPane.add(btnNovoCliente);
		
		JButton btnNewButton = new JButton("Pesquisar Cliente ");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				try {
					new clienteControle().pesquisarCliente(textFieldCpf.getText());
					FrmPesquisarCliente frame = new FrmPesquisarCliente();
					frame.setVisible(true);
				} catch (Erro_Cpf e) {
					JOptionPane.showMessageDialog(null, e.getMessage(), "Erro", JOptionPane.ERROR_MESSAGE);
					e.printStackTrace();
				}
				
			}
		});
		btnNewButton.setBounds(10, 215, 139, 23);
		contentPane.add(btnNewButton);
	}
	
	}

